<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
 <meta>
  <!-- Stylesheets -->
  <link href="web.css" type="text/css" rel="stylesheet"></link>
  <link href="pygmentize.css" type="text/css" rel="stylesheet"></link>
  <title>VLFeat - Download - Compiling</title>
  

  <!-- Scripts-->
  
 </meta>

 <!-- Body Start -->
 <body>
  <div id="header">
   <!-- Google CSE Search Box Begins -->
   <form action="http://www.vlfeat.org/search.html" method="get" id="cse-search-box" enctype="application/x-www-form-urlencoded">
    <div>
     <input type="hidden" name="cx" value="003215582122030917471:oq23albfeam"></input>
     <input type="hidden" name="cof" value="FORID:11"></input>
     <input type="hidden" name="ie" value="UTF-8"></input>
     <input type="text" name="q" size="31"></input>
     <input type="submit" name="sa" value="Search"></input>
    </div>
   </form>
   <script src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en" xml:space="preserve" type="text/javascript"></script>
   <!-- Google CSE Search Box Ends -->
   <h1><a shape="rect" href="index.html" class="plain"><span id="vlfeat">VLFeat</span><span id="dotorg">.org</span></a></h1>
  </div>
  <div id="headbanner">
   Download - Compiling
  </div>
  <div id="pagebody">
   <div id="sidebar"> <!-- Navigation Start -->
    <ul>
<li><a href="index.html">Home</a>
</li>
<li><a href="download.html">Download</a>
<ul>
<li><a href="install-matlab.html">MATLAB install</a>
</li>
<li><a href="install-shell.html">Shell install</a>
</li>
<li><a href="install-c.html">C library install</a>
</li>
<li><a href="compiling.html" class='active' >Compiling</a>
</li>
</ul></li>
<li><a href="doc.html">Documentation</a>
</li>
<li><a href="overview/tut.html">Tutorials</a>
</li>
<li><a href="applications/apps.html">Applications</a>
</li>
</ul>

   </div> <!-- sidebar -->
   <div id="content">
    
   

<p>These instructions explain how to compile VLFeat on your own. This
can be useful to customize or contribute to VLFeat, but it is
otherwise not necessary (use the
<a shape="rect" href="download.html">binary package</a> instead).</p>

<ul>
<li><a shape="rect" href="compiling.html#compiling.unix">Compiling on Unix</a></li>
<li><a shape="rect" href="compiling.html#compiling.windows">Compiling on Windows</a></li>
</ul>

<h1 id="compiling.unix">Compiling on Unix</h1>

<p>Compiling for UNIX-like platforms (e.g. Mac OS X, Linux) uses the
standard GNU toolchain. It is usually sufficient to change to VLFeat
root directory, denoted <code>VLFEATROOT</code> in the following, and
type <code>make</code>:</p>
<div class="highlight"><pre><span class="nv">$ </span><span class="nb">cd </span>VLFEATROOT
<span class="nv">$ </span>make
</pre></div>

<p>The make script attempts to automatically detect the host
architecture and configure itself accordingly. If the architecture is
not detected correctly, it can be specified manually. For instance</p>
<div class="highlight"><pre><span class="nv">$ </span>make <span class="nv">ARCH</span><span class="o">=</span>glnx86
</pre></div>

<p>compiles for GNU/Linux 32-bit. <code>make help</code> can be used
to obtain a list of other useful options.</p>

<p><b>MATLAB support.</b> In order for MATLAB support to be compiled,
the MATLAB <code>mex</code> script must be in the current path. If it
is not, its location must be passed to <code>make</code> as
follows. First, determine MATLAB's root directory by running a MATLAB
session and issuing the <code>matlabroot</code>
command. Let <code>MATLABROOT</code> denote the returned path
(e.g. <code>/Applications/MATLAB_R2009b.app/</code>). The <code>mex</code>
script is usually located in <code>MALTABROOT/bin/mex</code>. Then run
the compilation with the command</p>
<div class="highlight"><pre><span class="nv">$ </span>make <span class="nv">MEX</span><span class="o">=</span>MATLABROOT/bin/mex
</pre></div>

<p>VLFeat must be compiled for the architecture used by MATLAB (run
 MATLAB's <code>computer</code> command to obtain this
 information). On Mac OS X it is often necessary to turn on 64-bit
 support explicitly by setting <code>ARCH=maci64</code> as both the 32
 and 64 bit versions are plausible targets on 64-bit machines.</p>

<div class="parbox">
<p><b>Mac OS X 10.6 (Snow Leopard), 64-bit, and MATLAB 2009b.</b>
MATLAB 2009b for Snow Leopard has added 64 bit mex support and a
corresponding extension <code>mexmaci64</code>. VLFeat now supports
compiling for this platform, but the architecture must be specified
manually when compiling, either like:</p>

<div class="highlight"><pre><span class="nv">$ </span>make <span class="nv">ARCH</span><span class="o">=</span>maci64
</pre></div>


<p>or</p>

<div class="highlight"><pre><span class="nv">$ </span>make <span class="nv">ARCH</span><span class="o">=</span>maci
</pre></div>


<p>Unfortunately, MATLAB 2009b's <code>mex</code> script has a bug that
must be manually fixed in order for this procedure to work
correctly. It is recommend to make backup of the <code>mex</code>
script before attempting this. Th fix the bug, edit the
<code>MATLABROOT/bin/mex</code> script by cutting the line:</p>

<div class="highlight"><pre>get_arch    <span class="c"># Call $MATLAB/bin/util/arch.sh</span>
</pre></div>


<p>and pasting it after the processing of options:</p>

<div class="highlight"><pre>...
<span class="nb">shift</span>
<span class="k">done</span>

<span class="c">#PASTE get_arch call here</span>
get_arch    <span class="c"># Call $MATLAB/bin/util/arch.sh</span>

<span class="k">if</span> <span class="o">[</span> <span class="nv">$v7_compat</span> -eq 1 <span class="o">]</span> ; <span class="k">then</span>
<span class="nv">fc_flags</span><span class="o">=</span><span class="s2">&quot;$fc_flags -DMX_COMPAT_32&quot;</span>
...
</pre></div>

</div>

<h1 id="compiling.windows">Compiling on Windows</h1>

<p>For Windows, the library bundles an NMake makefile
 (<code>Makefile.mak</code>). In order to use it, you must edit
 Makefile.mak to adjust the values of a number of configuration
 variables to match your setup. Once you have done that, start the
 Visual Studio Command Prompt and type</p>

<div class="highlight"><pre><span class="nv">$ </span>nmake /f Makefile.mak <span class="c"># for the Windows 32 target</span>
<span class="nv">$ </span>nmake /f Makefile.mak <span class="nv">ARCH</span><span class="o">=</span>win64 <span class="c"># for the Windows 64 target</span>
</pre></div>


<p>For Windows platform, it is also possible to compile just the
MATLAB MEX files from within MATLAB (using the <code>vl_compile</code>
command). This is meant to help less experienced users that may need
to recompile the mex file due to binary incompatibilities with older
MATLAB versions.</p>

<div class="parbox">
<p><b>MATLAB 7.0 and earlier</b> require recompiling the MEX files by
 the provided <code>vl_compile</code> command.
</p>
</div>

<h3>Windows troubleshooting</h3>

<dl>
 <dt>syntax error: '=' unexpected:</dt>
 <dd><p>Use <code>nmake /f Makefile.mak</code>.
   Without <code>/f</code>, nmake will default to the wrong
   makefile.</p></dd>
 <dt>'long' followed by 'long' is illegal:</dt>
 <dd><p>This error is usually caused by
   attempting to compile outside of the Visual Studio Command Prompt.</p></dd>
</dl>



  
   </div>
   <div class="clear">&nbsp;</div>
  </div> <!-- pagebody -->
  <div id="footer">
   &copy; 2007-12 Andrea Vedaldi and Brian Fulkerson
  </div> <!-- footer -->

  <!-- Google Analytics Begins -->
  <script xml:space="preserve" type="text/javascript">
   //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {
   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
   }
   //]]>
  </script>
  <script xml:space="preserve" type="text/javascript">
    //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {

   try {
   var pageTracker = _gat._getTracker("UA-4936091-2");
   pageTracker._trackPageview();
   } catch(err) {}

   }
   //]]>
  </script>
  <!-- Google Analytics Ends -->
 </body>
</html>

 